package com.muyu.danmo.controller;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.poi.ExcelUtil;
import com.muyu.common.core.web.controller.BaseController;
import com.muyu.common.log.annotation.Log;
import com.muyu.common.log.enums.BusinessType;
import com.muyu.danmo.domain.DanmoEngravingAtlas;
import com.muyu.danmo.service.IDanmoEngravingAtlasService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 刻字图片集Controller
 * 
 * @author yangle
 * @date 2024-11-26
 */
@RestController
@RequestMapping("/danmoEngravingAtlas")
public class DanmoEngravingAtlasController extends BaseController
{
    @Autowired
    private IDanmoEngravingAtlasService danmoEngravingAtlasService;

    /**
     * 查询刻字图片集列表
     */
//    @RequiresPermissions("system:danmoEngravingAtlas:list")
    @PostMapping("/list")
    public Result<PageInfo<DanmoEngravingAtlas>> list(@RequestBody DanmoEngravingAtlas danmoEngravingAtlas)
    {
        PageHelper.startPage(danmoEngravingAtlas.getPageNum(),danmoEngravingAtlas.getPageSize());
        List<DanmoEngravingAtlas> list = danmoEngravingAtlasService.selectDanmoEngravingAtlasList(danmoEngravingAtlas);

        PageInfo<DanmoEngravingAtlas> danmoEngravingAtlasPageInfo = new PageInfo<>(list);
        return Result.success(danmoEngravingAtlasPageInfo);
    }

    /**
     * 导出刻字图片集列表
     */
//    @RequiresPermissions("system:danmoEngravingAtlas:export")
    @Log(title = "刻字图片集", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DanmoEngravingAtlas danmoEngravingAtlas)
    {
        List<DanmoEngravingAtlas> list = danmoEngravingAtlasService.selectDanmoEngravingAtlasList(danmoEngravingAtlas);
        ExcelUtil<DanmoEngravingAtlas> util = new ExcelUtil<DanmoEngravingAtlas>(DanmoEngravingAtlas.class);
        util.exportExcel(response, list, "刻字图片集数据");
    }

    /**
     * 获取刻字图片集详细信息
     */
//    @RequiresPermissions("system:danmoEngravingAtlas:query")
    @GetMapping(value = "/{id}")
    public Result getInfo(@PathVariable("id") Long id)
    {
        return success(danmoEngravingAtlasService.selectDanmoEngravingAtlasById(id));
    }

    /**
     * 新增刻字图片集
     */
//    @RequiresPermissions("system:danmoEngravingAtlas:add")
    @Log(title = "刻字图片集", businessType = BusinessType.INSERT)
    @PostMapping
    public Result add(@RequestBody DanmoEngravingAtlas danmoEngravingAtlas)
    {
        return toAjax(danmoEngravingAtlasService.insertDanmoEngravingAtlas(danmoEngravingAtlas));
    }

    /**
     * 修改刻字图片集
     */
//    @RequiresPermissions("system:danmoEngravingAtlas:edit")
    @Log(title = "刻字图片集", businessType = BusinessType.UPDATE)
    @PutMapping
    public Result edit(@RequestBody DanmoEngravingAtlas danmoEngravingAtlas)
    {
        return toAjax(danmoEngravingAtlasService.updateDanmoEngravingAtlas(danmoEngravingAtlas));
    }

    /**
     * 删除刻字图片集
     */
//    @RequiresPermissions("system:danmoEngravingAtlas:remove")
    @Log(title = "刻字图片集", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public Result remove(@PathVariable Long[] ids)
    {
        return toAjax(danmoEngravingAtlasService.deleteDanmoEngravingAtlasByIds(ids));
    }
}
